package com.zw.april14thh.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zw.april14thh.dao.AdminUserDao;
import com.zw.april14thh.entity.AdminUser;
import com.zw.april14thh.service.AdminUserService;
import com.zw.april14thh.vo.AjaxResult;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authc.UsernamePasswordToken;
import org.apache.shiro.session.Session;
import org.apache.shiro.subject.PrincipalCollection;
import org.apache.shiro.subject.Subject;
import org.springframework.stereotype.Service;

import java.time.LocalDate;

@Service
public class AdminUserServiceImpl extends ServiceImpl<AdminUserDao, AdminUser> implements AdminUserService {

    @Override
    public void login(String username, String password, boolean rememberMe) {
        Subject subject = SecurityUtils.getSubject();
        UsernamePasswordToken usernamePasswordToken = new UsernamePasswordToken(username, password,rememberMe);
        subject.login(usernamePasswordToken);

    }

    @Override
    public AjaxResult changeWindowId(Integer windowId,Integer adminId) {


        AdminUser byId = getById(adminId);
        byId.setWindowId(windowId);
        updateById(byId);

        return AjaxResult.success();
    }
}
